<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>小贷回购表管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 60px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">回购户名</div>
                    <div class="field">
                        <select name="repoSubject" id="repoSubject">
                            <option value="">全部</option>
                            <option value="1">天津卓远</option>
                            <option value="2">狮桥</option>
                        </select>
                    </div>
                </div>

                <div class="fieldBox">
                    <div class="label">贷款合同号</div>
                    <div class="field">
                        <input name="crCntNo" id="crCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label" style="width:100px">结清金额是否一致</div>
                    <div class="field">
                        <select name="settle" id="settle">
                        	<option value="">全部</option>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>

                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null, callback = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/mcr/mcrBillMRe/initList.do?cstTypeCd=0',
            method: 'get',
            columns: [
                {display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left',
                    render:function(rowdata,rowindex,value){
                        return '<a href="javascript:;" onclick="showCstDtl('+rowdata.cstId+')"><span class="gridTip" title="客户查看">'+rowdata.cstNm+'</span></a>';
                    }
                },
                {display: '客户ID', name: 'cstId', minWidth: 180, align: 'left',
                    render:function(rowdata,rowindex,value){
                        return '<a href="javascript:;" onclick="showCstDtl('+rowdata.cstId+')"><span class="gridTip" title="客户查看">'+rowdata.cstId+'</span></a>';
                    }
                },
                {display: '贷款合同号', name: 'crCntNo', minWidth: 110, align: 'left',
                    render:function(rowdata,index,value){
                        return '<a href="javascript:;" style="cursor: pointer;" onclick="billDtl('+rowdata.billID+')">'+rowdata.crCntNo+'</a>';
                    }
                },
                {display: '回购贷款合同号', name: 'crCntNoNew', minWidth: 110, align: 'left',
                    render:function(rowdata,index,value){
                        return '<a href="javascript:;" style="cursor: pointer;" onclick="billDtlNew('+rowdata.id+')">'+rowdata.crCntNoNew+'</a>';
                    }
                },
                {display: '放款金额', name: 'crAmt', minWidth: 80, align: 'right',
                    render:function(rowdata,index,value){
                        if(rowdata.crAmt){
                            return '&yen;'+FormatMoney(rowdata.crAmt/100);
                        }
                    }
                },
                {display: '放款时间', name: 'crDt', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                {display: '是否结清', name: 'isSettle', minWidth: 100, align: 'center', enabledSort: false,
                    render:function (rowData) {
                        if (rowData.isSettle == 1){
                            return "是";
                        }else {
                            return "否"
                        }
                    }
                },
                {display: '回购户名', name: 'repoSubject', minWidth: 100, align: 'center', enabledSort: false,
                    render:function(rowData){
                        if(rowData.repoSubject== 1){
                            return "天津卓远融资担保有限公司";
                        }else if (rowData.repoSubject == 2){
                            return "狮桥融资租赁（中国）有限公司";
                        }else {
                            return "";
                        }
                    }
                },
                {display: '创建日期', name: 'mdfTm', minWidth: 150, align: 'center', enabledSort: false,render:renderDate},
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);
        grid.toggleCol('repSts', false);
        grid.toggleCol('loanChannel', false);


        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
            form.setData({  //重置select等特殊表单
    		    "settle":"",
    		    "repoSubject":""
    		  });
        });

        callback = function () {
            grid.reload();
        };

    });

    //查询客户详情
    function showCstDtl(_cstId) {
        Add_navTab("MCR_BILL_M_" + _cstId, "客户信息", '<%=path%>/customer/cstbscinfo/toCustDetailPage.do?id=' + _cstId, null);
    }
    //查看账单详情
    function billDtl(billId){
        Add_navTab('MCR_BILL_M_'+billId,'小贷账单详情',"<%=path%>/mcr/mcrBillM/toBillDtlPage.do?id="+billId);
    }

    function billDtlNew(billId){
        Add_navTab('MCR_BILL_M_'+billId,'小贷回购账单详情',"<%=path%>/mcr/mcrBillMRe/toBillDtlPage.do?id="+billId);
    }
        //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

</script>

</body>
</html>
